<?php
namespace app\base\controller;
use app\rbac\model\AdminM;
use think\Controller;
use think\Db;
use think\Session;

class Login extends Controller
{

    /**
     * 登录
     * @return mixed
     */
    public function login()
    {
        if ($this->request->isPost()) {
            $data = $this->request->post();
            $model = new AdminM();
            $model->login($data);
            return json(['code' => $model->code, 'msg' => $model->msg]);
        }
        return $this->fetch();
    }

    public function logout()
    {
        Session::clear();
        $this->redirect('base/Login/login');
    }

}